package com.example.demo.model;

import com.example.demo.enums.ResultStatus;
import lombok.Data;

@Data
public class Result <T>{
    private ResultStatus status;
    private String errMsg;
    private T data;

    public static <T> Result success(T data) {
        Result ret = new Result();
        ret.status = ResultStatus.SUCCESS;
        ret.errMsg = "";
        ret.data = data;
        return ret;
    }

    public static Result fail(String msg) {
        Result ret = new Result();
        ret.status = ResultStatus.FAIL;
        ret.errMsg = msg;
        ret.data = null;
        return ret;
    }

    public static Result nologin() {
        Result ret = new Result();
        ret.status = ResultStatus.NOLOGIN;
        ret.errMsg = "用户未登录";
        ret.data = null;
        return ret;
    }
}
